package net.ojbk.study.curriculumDesign.service.cilentservicer.impl;

import net.ojbk.study.curriculumDesign.beans.cilentservicer.Chat;
import net.ojbk.study.curriculumDesign.beans.cilentservicer.ServiceRecord;
import net.ojbk.study.curriculumDesign.beans.usermanage.User;
import net.ojbk.study.curriculumDesign.dao.cilentservicer.ServiceRecordDao;
import net.ojbk.study.curriculumDesign.service.cilentservicer.ICustomerManaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: twobox
 * Date: 2019/1/8
 * Time: 23:09
 * Description: No Description
 */
@Service("customerManaService")
public class CustomerManaServiceImpl implements ICustomerManaService {
    @Autowired
    @Qualifier("serviceRecordDao")
    ServiceRecordDao serviceRecordDao;

    /**
     * 查询用户所有的被服务记录
     *
     * @param user
     * @return
     */
    @Override
    public List<ServiceRecord> getAllSerRec(User user) {
        List<ServiceRecord> serviceRecords = serviceRecordDao.selectAllByUser(user);
        /*System.out.println("大小" + serviceRecords.size());
        for (ServiceRecord r : serviceRecords) {
            System.out.println("1" + serviceRecords);
        }*/
        return serviceRecords;
    }

    /**
     * 用户的本次会话是否有新消息
     *
     * @param chat 会话
     * @return
     */
    @Override
    public boolean isHaveNewMsg(Chat chat) throws Exception {
        return !chat.getCuserNewMsgList().isEmpty();
    }
}
